import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-04-06
 * Time: 21:18
 */
public class demo2 {
    public static void main(String[] args) {
        Object locker = new Object();
        Object locker2 = new Object();

        Thread t1 = new Thread(() ->{
           try {
               System.out.println("wait 之前");
               synchronized (locker){
                   locker.wait();
               }
               System.out.println("wait 之后");
           }catch (InterruptedException e){
               throw new RuntimeException();
           }
        });

        Thread t2 = new Thread(() -> {
            Scanner sc = new Scanner(System.in);
            System.out.println("输入任意内容, 通知唤醒 t1");
            sc.next();
            synchronized (locker){
                locker.notify();
            }
        });


        t1.start();
        t2.start();
    }
}
